﻿/*
 * Reflector from Microsoft.Synchronization.Data.DbSyncBatchSerializationBinder
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using System.Globalization;

namespace SyncLib.Data
{
    public class KpSyncBatchSerializationBinder : SerializationBinder
    {
        public override Type BindToType(string assemblyName, string typeName)
        {
            if (assemblyName.Contains("Microsoft.Synchronization"))
            {
                string fullName = Assembly.GetExecutingAssembly().FullName;
                return Type.GetType(string.Format(CultureInfo.InvariantCulture, "{0}, {1}", new object[] { typeName, fullName }));
            }
            return Type.GetType(string.Format(CultureInfo.InvariantCulture, "{0}, {1}", new object[] { typeName, assemblyName }));
        }
    }
}
